//
//  B_IntegralDetailVC.m
//  DreamOf
//
//  Created by 薛小刚 on 2018/8/27.
//  Copyright © 2018年 薛小刚. All rights reserved.
//

#import "B_IntegralDetailVC.h"
#import "B_ReleaseFooterView.h"
#import "B_IntegralDetailHeaderView.h"
#import "B_IntegralDetailTVC.h"

@interface B_IntegralDetailVC ()

@property (nonatomic, strong) BaseView * mainView;

@property (nonatomic, strong) B_ReleaseFooterView * footerView;

@end

@implementation B_IntegralDetailVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setTitle:@"积分详情"];
    self.view = self.mainView;
}


- (BaseView *)mainView {
    if (!_mainView) {
        _mainView = [[BaseView alloc] init];
        [_mainView addSubview:self.footerView];
        [self.footerView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.mainView.mas_left);
            make.right.equalTo(self.mainView.mas_right);
            make.bottom.equalTo(self.mainView.mas_bottom);
            make.height.equalTo(@(80));
        }];
        CGFloat bottom = SCREEN_HEIGHT > 800 ? (80 + 24) : 80;
        [_mainView setTableViewFrameWithTop:5 left:0 right:0 bottom:-bottom];
        [_mainView.tableView registerNib:[UINib nibWithNibName:@"B_IntegralDetailTVC" bundle:nil] forCellReuseIdentifier:@"B_IntegralDetailTVC"];
        _mainView.numberOfSectionsBlock = ^NSInteger(UITableView *tableView) {
            return 1;
        };
        _mainView.numberOfRowsBlock = ^NSInteger(UITableView *tableView, NSInteger section) {
            return 10;
        };
        _mainView.viewForHeaderBlock = ^UIView *(UITableView *tableView, NSInteger section) {
            B_IntegralDetailHeaderView * header = [B_IntegralDetailHeaderView initB_IntegralDetailHeaderView];
            header.B_goodsImageView.backgroundColor = [UIColor whiteColor];
            header.B_titleLabel.text = @"体脂称";
            header.B_integralLabel.text = @"15000积分";
            return header;
        };
        _mainView.cellForRowBlock = ^UITableViewCell *(UITableView *tableView, NSIndexPath *indexPath) {
            B_IntegralDetailTVC * cell = [tableView dequeueReusableCellWithIdentifier:@"B_IntegralDetailTVC" forIndexPath:indexPath];
            cell.B_titleLabel.text = @"1.兑换前务必注意, 积分仅用来兑换本商品, 兑换成功, 积分不予退还.";
            
            return cell;
        };
    }
    return _mainView;
}

- (B_ReleaseFooterView *)footerView {
    if (!_footerView) {
        _footerView = [B_ReleaseFooterView initB_ReleaseFooterView];
        _footerView.B_SureButton.backgroundColor = [UIColor color_content_background_color];
        [_footerView.B_SureButton setTitle:@"积分不足" forState:UIControlStateNormal];
        _footerView.sureActionBlock = ^{
            //TODO:如果积分足够 在这里执行兑换操作;
        };
    }
    return _footerView;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];

    
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
